import { createRouter, createWebHashHistory } from 'vue-router';

export default createRouter({
	// 路由模式
	history: createWebHashHistory(),
	routes: [
		{
			path: '/',
			redirect: '/home',
		},
		{
			path: '/home',
			component: () => import('@/pages/home/index.vue'),
			meta: {
				title: '首页',
			},
		},
		{
			path: '/hospital',
			component: () => import('@/pages/hospital/index.vue'),
			redirect: '/hospital/register',
			children: [
				{
					path: 'register',
					component: () => import('@/pages/hospital/register/index.vue'),
					meta: {
						title: '预约挂号',
					},
				},
				{
					path: 'detail',
					component: () => import('@/pages/hospital/detail/index.vue'),
					meta: {
						title: '医院详情',
					},
				},
				{
					path: 'notice',
					component: () => import('@/pages/hospital/notice/index.vue'),
					meta: {
						title: '预约须知',
					},
				},
				{
					path: 'close',
					component: () => import('@/pages/hospital/close/index.vue'),
					meta: {
						title: '停诊信息',
					},
				},
				{
					path: 'search',
					component: () => import('@/pages/hospital/search/index.vue'),
					meta: {
						title: '查询/取消',
					},
				},
				{
					path: 'register_step1',
					component: () => import('@/pages/hospital/register/register_step1.vue'),
					meta: {
						title: '预约挂号',
						requiredLogin: true,
					},
				},
				{
					path: 'register_step2',
					component: () => import('@/pages/hospital/register/register_step2.vue'),
					meta: {
						title: '预约挂号',
						requiredLogin: true,
					},
				},
			],
		},
		{
			path: '/wxlogin',
			component: () => import('@/pages/wxlogin/index.vue'),
			meta: {
				title: '微信登录',
			},
		},
		{
			path: '/user',
			component: () => import('@/pages/user/index.vue'),
			redirect: '/user/order',
			children: [
				{
					path: 'certification',
					component: () => import('@/pages/user/certification/index.vue'),
					meta: {
						title: '实名认证',
						requiredLogin: true,
					},
				},
				{
					path: 'order',
					component: () => import('@/pages/user/order/index.vue'),
					meta: {
						title: '挂号订单',
						requiredLogin: true,
					},
				},
				{
					path: 'patient',
					component: () => import('@/pages/user/patient/index.vue'),
					meta: {
						title: '就诊人管理',
						requiredLogin: true,
					},
				},
				{
					path: 'profile',
					component: () => import('@/pages/user/profile/index.vue'),
					meta: {
						title: '账号管理',
						requiredLogin: true,
					},
				},
				{
					path: 'feedback',
					component: () => import('@/pages/user/feedback/index.vue'),
					meta: {
						title: '意见反馈',
						requiredLogin: true,
					},
				},
			],
		},
	],
	// 切换页面时滚动条的行为
	scrollBehavior() {
		return {
			top: 0,
			left: 0,
		};
	},
});
